if [ ! -d master ]; then
    mkdir master slave1 slave2 sentinel1 sentinel2 sentinel3
fi

echo 'staring master...'
cp master.conf master/master.conf
redis-server ./master.conf

sleep 5

echo 'starting slave1...'
cp slave1.conf slave1/slave1.conf
redis-server ./slave1.conf

echo 'starting slave2...'
cp slave2.conf slave2/slave2.conf
redis-server ./slave2.conf

sleep 5

echo 'starting sentinel1...'
cp sentinel.conf sentinel1/sentinel1.conf
redis-sentinel ./sentinel1/sentinel1.conf --port 16380 --dir './sentinel1' --logfile 'sentinel1.log'

echo 'starting sentinel2...'
cp sentinel.conf ./sentinel2/sentinel2.conf
redis-sentinel ./sentinel2/sentinel2.conf --port 26380 --dir './sentinel2' --logfile 'sentinel2.log'

echo 'starting sentinel3...'
cp sentinel.conf ./sentinel3/sentinel3.conf
redis-sentinel ./sentinel3/sentinel3.conf --port 36380 --dir './sentinel3' --logfile 'sentinel3.log'

rm -f *.log
